package com.ambition.demo.design.proxy;

import com.ambition.demo.design.proxy.service.OrderService;
import com.ambition.demo.design.proxy.service.impl.OderServiceImpl;

public class OrderProxy implements OrderService{

    private OrderService orderService;

    public OrderProxy(OrderService orderService) {
        this.orderService = orderService;
    }

    @Override
    public void createOrder() {
        long l = System.currentTimeMillis();
        orderService.createOrder();
        long l1 = System.currentTimeMillis();
        System.out.println("耗时："+(l1-l));
    }

    @Override
    public void detail() {
        long l = System.currentTimeMillis();
        orderService.detail();
        long l1 = System.currentTimeMillis();
        System.out.println("耗时："+(l1-l));

    }

    @Override
    public void modify() {
        long l = System.currentTimeMillis();
        orderService.modify();
        long l1 = System.currentTimeMillis();
        System.out.println("耗时："+(l1-l));
    }


    public static void main(String[] args) {
        OrderService orderService = new OderServiceImpl();
        OrderProxy orderProxy = new OrderProxy(orderService);
        orderProxy.createOrder();
        orderProxy.detail();
        orderProxy.modify();
    }
}
